<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript Let</title>
</head>

<h1>使用 var 声明变量</h1>

<p id="demo"></p>

<script>
  var  x = 10;
  // Here x is 10
  {
    var x = 2;
    // Here x is 2
  }
  // Here x is 2 在块中重新声明变量也将重新声明块外的变量
  document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>